djgoulart
(usa Debian)
Enviado em 24/06/2009 - 13:06h
Eu mudei de idéia e refiz o script do firewall, daí ele passou a rotear a conecção de internet normalmente, só que surgiu um outro problema.
As regras do Squid nao estao surtindo efeito, ele está em modo trasnparente. Segue abaixo como ficou o script do firewall e do squid.
O unico problema que está dando por enquanto é esse, o squid nao está bloqueando as paginas e o intuido dele é bloquear todas as paginas exeto as que eu especificar.
============================FIREWALL ================================
#!/bin/bash
iniciar(){
# Compartilha a conexão
modprobe ip_nat_ftp
modprobe iptable_nat
IPTABLES=/usr/sbin/iptables
echo 1 > /proc/sys/net/ipv4/ip_forward
$IPTABLES -t nat -A POSTROUTING -o eth0 -j MASQUERADE
echo "Ativando compartilhamento!"
# Proxy transparente
$IPTABLES -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128
#Entrada
$IPTABLES -A INPUT -p tcp -s 192.168.1.0/24 -d 74.86.157.115 --dport 110 -j ACCEPT
$IPTABLES -A INPUT -p tcp -s 192.168.1.0/24 -d 74.86.157.115 --dport 25 -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 22 -j ACCEPT #Ssh
$IPTABLES -A INPUT -p tcp --dport 25 -j ACCEPT #SMTP
$IPTABLES -A INPUT -p tcp --dport 110 -j ACCEPT #POP
$IPTABLES -A INPUT -p tcp --dport 443 -j ACCEPT #HTTPS
$IPTABLES -A INPUT -p tcp --dport 80 -j ACCEPT #HTTP
$IPTABLES -A INPUT -p tcp --dport 5590 -j ACCEPT #HTTPj REDIRECT --to-port 3128
# OUTPUT (Pacotes que sai da rede)
#---------------------------------------------------------------------------
$IPTABLES -A OUTPUT -p tcp -s 192.168.1.0/24 -d 74.86.157.115 --dport 110 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp -s 192.168.1.0/24 -d 74.86.157.115 --dport 25 -j ACCEPT
$IPTABLES -A OUTPUT -p tcp --dport 22 -j ACCEPT #ssh
$IPTABLES -A OUTPUT -p tcp --dport 25 -j ACCEPT #SMTP
$IPTABLES -A OUTPUT -p tcp --dport 110 -j ACCEPT #POP
$IPTABLES -A OUTPUT -p tcp --dport 80 -j ACCEPT #HTTP
$IPTABLES -A OUTPUT -p tcp --dport 443 -j ACCEPT #HTTPS
# FORWARD (REDE LOCAL)
#---------------------------------------------------------------------------
$IPTABLES -A FORWARD -p tcp --dport 22 -j ACCEPT # ssh
$IPTABLES -A FORWARD -p tcp --dport 3389 -j ACCEPT #Remote_Desktop_win-2003-Server
$IPTABLES -A FORWARD -p tcp --dport 25 -j ACCEPT # SMTP
$IPTABLES -A FORWARD -p tcp --sport 110 -j ACCEPT #POP
$IPTABLES -A FORWARD -p tcp --sport 25 -j ACCEPT #SMTP
$IPTABLES -A FORWARD -p tcp --dport 8333 -j ACCEPT #POP
$IPTABLES -A FORWARD -p tcp --dport 443 -j ACCEPT
# FORWARD (REDE LOCAL)
#---------------------------------------------------------------------------
$IPTABLES -A FORWARD -p tcp --dport 22 -j ACCEPT # ssh
$IPTABLES -A FORWARD -p tcp --dport 3389 -j ACCEPT #Remote_Desktop_win-2003-Server
$IPTABLES -A FORWARD -p tcp --dport 25 -j ACCEPT # SMTP
$IPTABLES -A FORWARD -p tcp --sport 110 -j ACCEPT #POP
$IPTABLES -A FORWARD -p tcp --sport 25 -j ACCEPT #SMTP
$IPTABLES -A FORWARD -p tcp --dport 8333 -j ACCEPT #POP
$IPTABLES -A FORWARD -p tcp --dport 443 -j ACCEPT
$IPTABLES -A FORWARD -s 192.168.1.0/24 -p tcp --dport 1863 -j REJECT
$IPTABLES -A FORWARD -s 192.168.1.0/24 -j ACCEPT
#---------------------------------------------------------------------------
echo "Firewall Ativado"
}
parar(){
iptables -F
iptables -t nat -F
echo "Regras de firewall e compartilhamento desativados"
}
case "$1" in
"start") iniciar ;;
"stop") parar ;;
"restart") parar; iniciar ;;
*) echo "Use os parâmetros start ou stop"
esac
===============================SQUID=================================
http_port 3128 transparent
visible_hostname starfire
cache_mem 128 MB
maximum_object_size_in_memory 1024 KB
maximum_object_size 512 MB
minimum_object_size 0 KB
cache_swap_low 90
cache_swap_high 95
cache_dir ufs /var/spool/squid 2048 16 256
cache_access_log /var/log/squid/access.log
refresh_pattern ^ftp: 15 20% 2280
refresh_pattern ^gopher: 15 0% 2280
refresh_pattern . 15 20% 2280
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 901 # SWAT
acl Safe_ports port 110 # pop
acl Safe_ports port 25 # SMTP
acl Safe_ports port 22 #SSH
acl purge method PURGE
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
acl permitidos url_regex -i "/etc/squid/permitidos"
http_access allow permitidos
acl redelocal src 192.168.1.0/24
http_access allow localhost
http_access allow redelocal
http_access deny all
=====================================================================
Onde será que esta o erro ?